home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Word Perfect Main Street:…th Treasure of the Tombs
/
WordPerfect Main Street - Memphis Math Treasure of the Tombs.iso
/
cdefs.hpp
< prev
next >
Wrap
Text File
|
1994-08-26
|
9KB
|
198 lines
//=============================================================================
//CDEFS.HPP
// Waterford Sandy common definitions.
//
// Version Date Comment
// 0.9 081894 pre-release
// 1.0 082594 release
//
// Required link libraries: -none-
// Tab size: 2
//=============================================================================
/* exclude multiple includes */
#if !defined (__CDEFS_HPP)
#define __CDEFS_HPP
/* include files */
#if !defined (__NOINCLUDE)
#ifndef __WINDOWS_H
#include <windows.h>
#endif
#endif
/* exception codes: 80386+ exception codes */
#define EXC_DIVIDE 0 //divide error
#define EXC_DEBUG 1 //debugger interrupt
#define EXC_NMI 2 //nonmaskable-interrupt
#define EXC_BREAKPOINT 3 //breakpoint
#define EXC_OVERFLOW 4 //interrupt on overflow (INTO)
#define EXC_ARRAYBOUND 5 //array boundary violation (BOUND)
#define EXC_INVOPCODE 6 //invalid opcode
#define EXC_COPROCESSORNA 7 //coprocessor not available
#define EXC_DOUBLEFAULT 8 //double fault
#define EXC_COPROCESSORSEG 9 //coprocessor segment overrun
#define EXC_INVALIDTSS 10 //invalid TSS (task state segment)
#define EXC_SEGMENTNOTPRESENT 11 //segment not present
#define EXC_STACK 12 //stack exception
#define EXC_GP 13 //general protectin violation
#define EXC_PAGEFAULT 14 //page fault
#define EXC_COPROCESSORERR 16 //coprocessor error
#define EXC_ALIGNMENT 17 //alignment check (80486+)
/* exit codes: use when returning from WinMain */
#define EXIT_NORMAL 0 //returning normally
#define EXIT_INVALIDPARAM 1 //invalid command line parameter/argument
#define EXIT_NOMEMORY 2 //unable to allocate necessary memory
#define EXIT_INVALIDCONFIG 3 //invalid system configuration
#define EXIT_ASSERTIONFAILED 101 //assertion failed
#define EXIT_INVALIDTAG 102 //invalid object tag
/* length definitions, not including NULL terminator */
#define CBMAX_STRING 255 //general purpose string length
#define CBMAX_RCSTRING 255 //max resource string length
#define CBMAX_PATHFILE 127 //max path and file length
#define CBMAX_PATH 127 //max path length
#define CBMAX_DRIVE 2 //max drive letter and colon length
#define CBMAX_FILENAME 8 //max file name without extension length
#define CBMAX_EXT 3 //max extension length, not including separating period
#define CBMAX_FILE (CBMAX_FILENAME+1+CBMAX_EXT) //max file, dot, extension
#define CBMAX_PROFILE_NAME (CBMAX_FILE) //max profile name length
#define CBMAX_PROFILE_SECTION 80 //max profile section name length
#define CBMAX_PROFILE_ENTRY 80 //max profile entry name length
/* helper macros */
#define PUBLIC //public (global) scope
#define PRIVATE static //private (local) scope
#define IMPORT extern //import data
#define EXPORT //export data
#if !defined (NULL)
#define NULL 0 //NULL value
#endif
#define FALSE 0
#define TRUE 1
#define GARBAGE 0xCC //easily recognizable garbage value (204d 11001100b)
#define PALVERSION 0x0300 //palette version
#define MIN(a,b) (((a)<(b))?(a):(b)) //minimum value macro, use with caution
#define MAX(a,b) (((a)>(b))?(a):(b)) //maximum value macro, use with caution
#define ROUND(val,type) ((type)((val)+(((val)<0.0)?(-0.5):(0.5)))) //round value of specified type
#define SETBITFLAG(bf,dest) ((dest)|=(bf)) //set bitflags in dest
#define CLEARBITFLAG(bf,dest) ((dest)&=(~(bf))) //clear bitflags in dest
#define ISBITFLAGSET(bf,val) ((val)&(bf)) //test bitflags in val
#define SETBIT(bit,dest) ((dest)|=(1<<(bit))) //set bit
#define CLEARBIT(bit,dest) ((dest)&=(~(1<<(bit)))) //clear bit
#define ISBITSET(bit,val) ((val)&(1<<(bit))) //test bit
#if defined (SELECTOROF) //default SELECTOROF macro doesn't convert to far pointer
#undef SELECTOROF
#endif
#define SELECTOROF(lp) ((UINT)HIWORD((void far *)lp))
#if defined (OFFSETOF) //default OFFSETOF macro doesn't convert to far pointer
#undef OFFSETOF
#endif
#define OFFSETOF(lp) ((UINT)LOWORD((void far *)lp))
#define RECTWIDTH(rc) ((rc).right-(rc).left) //width of normalized rect
#define RECTHEIGHT(rc) ((rc).bottom-(rc).top) //height of normalized rect
#define FIELDSIZE(type,field) ((UINT)(sizeof(((type near *)1)->field))) //size of field in structure
#define GlobalLockCount(hg) (GlobalFlags(hg)&GMEM_LOCKCOUNT) //lock count of global object
#define GlobalIsDiscarded(hg) (GlobalFlags(hg)&GMEM_DISCARDED) //discarded test of global object
/* type defintions */
#if !defined (RC_INVOKED) //exclude non-resource definitions
#define HUGE _huge //misc types
#define VOID void
typedef unsigned int * PUINT;
typedef unsigned long int ULONG;
typedef char CHAR;
typedef struct tagDIMS { //dimension structure: left, top, width, height
int left;
int top;
int width;
int height;
} DIMS,
* PDIMS,
near * NPDIMS,
far * LPDIMS;
typedef int INT;
typedef signed char INT8; //fixed bit width types
typedef int INT16;
typedef long int INT32;
typedef unsigned char UINT8;
typedef unsigned int UINT16;
typedef unsigned long int UINT32;
typedef char SZ; //NULL terminated string
typedef char * PSZ;
typedef char near * NPSZ;
typedef char far * LPSZ;
typedef float FLOAT; //floating point
typedef double DPFLOAT;
typedef double DOUBLE;
typedef void * PVOID; //void pointers
typedef void near * NPVOID;
/* assertion macros */
//Conditional compile defines
// __ASSERT - use macros, automatically turned on if debug defined, unless specifically turned off
// __NOASSERT - do not use macros
//
//Macros
// ASSERT (condition) - Asserts that the specified condition is true.
#if defined ( __DEBUG)
#if !defined (__NOASSERT)
#define __ASSERT
#endif
#endif
#if defined (__ASSERT)
#define ASSERT(c) { \
if (!(c)) { \
SZ sz[60+1]; \
wsprintf(sz, "Module %s, %u\nTerminate application?", (LPSZ)__FILE__, (UINT)__LINE__); \
if (MessageBox (NULL, sz, "FAILURE: Assertion", MB_YESNO|MB_SYSTEMMODAL) == IDYES) \
exit (EXIT_ASSERTIONFAILED); \
asm int 3; \
} \
}
#else
#define ASSERT(c) 0
#endif
/* tag definitions/macros */
//Conditional compile defines
// __TAG - use macros, automatically turned on if debug defined, unless specifically turned off
// __NOTAG - do not use macros
//
//Types
// TAG - Tag type
//
//Macros
// MAKE_TAG (c0, c1, c2, c3) - Macro that takes four characters and returns a tag value.
// VALIDATE_TAG (tag, definition) - Validates a tag against its definition.
#if defined (__DEBUG)
#if !defined (__NOTAG)
#define __TAG
#endif
#endif
typedef unsigned long TAG;
#define MAKE_TAG(c0,c1,c2,c3) ((TAG)(BYTE)(c0)|((TAG)(BYTE)(c1)<<8)|((TAG)(BYTE)(c2)<<16)|((TAG)(BYTE)(c3)<<24))
#if defined (__TAG)
#define VALIDATE_TAG(t,def) { \
if ((t) != (def)) { \
SZ sz[60+1]; \
wsprintf (sz, "Module %s, %u : tag ('%c%c%c%c')\nTerminate application?", (LPSZ)__FILE__, (UINT)__LINE__, (CHAR)def, (CHAR)(def>>8), (CHAR)(def>>16), (CHAR)(def>>24)); \
if (MessageBox (NULL, sz, "FAILURE: Tag validation", MB_YESNO|MB_SYSTEMMODAL) == IDYES) \
exit (EXIT_INVALIDTAG); \
asm int 3; \
} \
}
#else
#define VALIDATE_TAG(t,d) 0
#endif
#if defined (__TAG) || defined (__ASSERT)
extern "C" void _cdecl exit (int); //required for assert and object tagging
#endif
#endif //RC_INVOKED
#endif //__CDEFS_HPP